<?php
namespace ManiaLivePlugins\MLEPP\Karma\Gui\Controls;

use ManiaLib\Gui\Elements\BgsPlayerCard;
use ManiaLib\Gui\Elements\Bgs1InRace;
use ManiaLib\Gui\Elements\Icons64x64_1;
use ManiaLib\Gui\Elements\Icons128x128_1;
use ManiaLib\Gui\Elements\BgRaceScore2;
use ManiaLib\Gui\Elements\Quad;
use ManiaLib\Gui\Elements\Label;

class Plus extends \ManiaLive\Gui\Windowing\Control
{
	public $callBack;
	public $sign;
	public $highlite;
	protected $PlusValue;
	private $gfxPlus;
	protected $gfxBackground;
	protected $login;

	function initializeComponents()
	{
		$this->PlusValue = $this->getParam(0);
		$this->highlite = $this->getParam(1);
		$this->login = $this->getParam(2);
		$this->sizeY = 2;
		$this->sizeX = 2;
		//$this->gfxBackground = new Quad();
		//$this->addComponent($this->gfxBackground);

		$this->gfxPlus = new Quad();
		$this->gfxPlus->setPosZ(-101);
		$this->gfxPlus->setValign("center");
		$this->gfxPlus->setPosY(0.5);
		$this->addComponent($this->gfxPlus);
	}

	function beforeDraw()
	{
		$sizeBig = 2.5;
		$sizeSmall =2;

		if ($this->sign == "plus") {
			$this->sizeY = $sizeBig;
			$this->sizeX = $sizeBig;
			//$this->gfxBackground->setSize($sizeBig,$sizeBig);
			$this->gfxPlus->setImage("http://koti.mbnet.fi/reaby/manialive/images/1up.png",true);
			$this->gfxPlus->setImageFocus("http://koti.mbnet.fi/reaby/manialive/images/1up_hover.png",true);
			$this->gfxPlus->setSize($sizeBig,$sizeBig);
		}
		else {
			$this->sizeY = $sizeSmall;
			$this->sizeX = $sizeSmall;
			$this->gfxPlus->setImage("http://koti.mbnet.fi/reaby/manialive/images/1down.png",true);
			$this->gfxPlus->setImageFocus("http://koti.mbnet.fi/reaby/manialive/images/1down_hover.png",true);
			$this->gfxPlus->setSize($sizeSmall,$sizeSmall);
		}

		/*if ($this->highlite == true) {
			$this->gfxPlus->setImageFocus("http://koti.mbnet.fi/reaby/manialive/images/1up_hover.png",true);
		}
		/*		else {
			$this->gfxBackground->setStyle(BgsPlayerCard::BgsPlayerCard);
			$this->gfxBackground->setSubStyle(BgsPlayerCard::BgPlayerCardBig);
		}*/

		$this->gfxPlus->setAction($this->callback('onClicked'));
		$this->gfxPlus->setVisibility(true);
		$this->gfxPlus->setPosZ(-101);
	}

	function onResize()
	{
	}

	function afterDraw() {}

	function onClicked($login)
	{
		call_user_func($this->callBack, $login, $this->PlusValue);
		//$this->redraw();
	}

	function destroy()
	{
		$this->callBack = null;
		parent::destroy();
	}
}
?>